[#macro menuListView]
<div>
    <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
        <span>确认要删除该条数据吗?</span>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="handleClose">确 定</el-button>
        </span>
    </el-dialog>
    <div>
        <el-table :data="tableData.list" style="width: 100%;margin-bottom: 20px;" row-key="id" border>
            <el-table-column prop="name" label="菜单名称" sortable width="200" align="left">
            </el-table-column>
            <el-table-column prop="icon" label="图标" width="50" align="center">
                <template slot-scope="scope">
                    <i :class="scope.row.icon"></i>
                </template>
            </el-table-column>
            <el-table-column prop="sortNum" label="排序号" width="80" align="center">
            </el-table-column>

            <el-table-column prop="catalog" label="功能类型" width="80" align="center">
                <template slot-scope="scope">
                    <span v-if="scope.row.catalog==0">菜单</span>
                    <span v-else>按钮</span>
                </template>
            </el-table-column>
            <el-table-column prop="catalog" label="菜单类型" width="80" align="center">
                <template slot-scope="scope">
                    <span v-if="scope.row.menuType==1">租户</span>
                    <span v-else>通用</span>
                </template>
            </el-table-column>
            <el-table-column prop="permission" label="权限" width="180">
            </el-table-column>
            <el-table-column prop="ids" label="菜单号" width="80">
            </el-table-column>

            <el-table-column prop="path" label="url">
            </el-table-column>
            <el-table-column label="操作" width="80" align="center">
                <template slot-scope="scope">
                    <el-button type="danger" size="mini" style="cursor: pointer;" @click="deleteData(scope.row)">删除
                    </el-button>
                </template>
            </el-table-column>
        </el-table>

    </div>
</div>
[/#macro]
[#macro menuListConfig]
<script type="text/x-template" id="my-menu-list">
	[@menuListView /]
</script>
<script type="text/javascript">


    var menuListConfig = {};
    menuListConfig.template = "#my-menu-list";
    menuListConfig.methods = config.basicMethod();


    menuListConfig.methods.addView = function () {
        this.$router.push({ path: 'add' });
    }
    menuListConfig.methods.editView = function (row) {
        var self = this;
        var data = {};
        data.id = row.id;
        this.$router.push({ path: 'update', query: data });

    }
    menuListConfig.methods.syncHandle = function (row) {
        var self = this;
        var params = {};
        params.id = row.id;
        this.postData("${siteurl}tenantRest/tenantmenu/sync.htm", params, function (res) {
            if (res.code == 0) {
                self.$message({
                    message: '同步菜单成功',
                    type: 'success'
                });
            } else {
                self.$message.error(res.msg);
            }
        });

    }


    menuListConfig.methods.changeTableSort = function (column) {
        this.searchObject.sortField = column.prop;
        if ("descending" == column.order) {
            this.searchObject.sortMethod = "desc";
        }
        else if ("ascending" == column.order) {
            this.searchObject.sortMethod = "asc";
        }
        else {
            this.searchObject.sortMethod = "";
        }
        this.getSearchList();
    }
    menuListConfig.methods.showView = function (row, column, cell, event) {
        if (cell.cellIndex > 0) {
            return;
        }
        var param = {};
        param.id = row.id;
        var self = this;
        this.$router.push({ path: 'view', query: param });

    }

    menuListConfig.methods.sizeChange = function (event) {
        this.searchObject.size = event;
        this.getSearchList();
    }
    menuListConfig.methods.pageChange = function (index) {
        this.searchObject.no = index;
        this.getSearchList();
    }
    menuListConfig.methods.getSearchList = function () {
        this.loading = true;
        var data = this.searchObject, that = this;
        data.level = 2;
        data.fetch = 1;
        data.sortField = "sortNum";
        data.sortMethod = "asc";
        $.post("${siteurl}tenantRest/tenantmenu/search.htm", data, function (result) {
            if (result.code == 0) {
                that.tableData = result;
            }
            setTimeout(function () {
                that.loading = false;
            }, 300)
        });
    }
    menuListConfig.methods.search = function () {
        this.searchObject.no = 1;
        this.getSearchList();
    }
    menuListConfig.methods.clearData = function () {
        this.searchObject.key = "";
        this.searchObject.name = "";
    }
    menuListConfig.methods.deleteData = function (event) {
        this.selectId = event.id;
        this.dialogVisible = true;
    }

    menuListConfig.methods.handleClose = function (done) {
        this.dialogVisible = false;
        var self = this;
        if (self.selectId) {
            var params = {};
            params.id = self.selectId;
            params.tenant = self.tenant;
            this.postData("${siteurl}tenantRest/tenantmenu/deleteSingle.htm", params, function (res) {
                if (res.code == 0) {
                    self.$message({
                        message: '删除数据成功',
                        type: 'success'
                    });
                    self.getSearchList();
                } else {
                    self.$message.error(res.msg);
                }
            });
        }

    }

    menuListConfig.computed = {};

    menuListConfig.data = function () {
        return {
            searchObject: {
                no: 1,
                size: 10,
                key: '',
                name: ''
            },
            dialogVisible: false,
            defaultProps: {
                children: 'children',
                label: 'name'
            },
            loading: false,
            showDialog: false,
            editDialog: false,
            tableData: {},
            form: {
                name: "",
                parent: "",
                sortNum: ""
            }
        }
    };

    menuListConfig.mounted = function () {
        this.selectId = this.$route.query.id;
        this.searchObject.tenant = this.selectId;
        this.tenant = this.selectId;
        this.getSearchList();
    }
    var menuListView = Vue.component('list-menu-view', menuListConfig);
</script>
[/#macro]